<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%
	request.setCharacterEncoding("utf-8");
%>
<%  
   if (request.getSession().getAttribute("Login") != null) 
   {
    String message = (String) request.getSession().getAttribute("Login");
    if (!message.equals("true"))
    {
     //如果登录标志不为true则跳转回登录页面
     response.sendRedirect("index.jsp");
    }
    else
    {
    	request.getSession().setAttribute("Login","true");
    }   
   }
   else
   {
    	response.sendRedirect("index.jsp");
   }
  %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>查看新闻</title>
<script type="text/javascript">
	function changePage() {
		var currentPage = document.getElementById("currentPage").value;
		window.self.location = "ShowNews?method=view&currentPage="+ currentPage;
	}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="ch-cn">
<style type="text/css">
body {
	background-color: #2E77ED;
}
</style>
</head>

<body>
<div align="center">
		<p>&nbsp;</p>
		<p><img src="<%=request.getContextPath()%>/PIC/top.jpg" width="820"
				height="115"></p>
		<table width="534" border="0" align="center">
			<tr>
				<td width="217">
				  <div align="center"><a href="AddNewsMain.jsp">添加新闻</a>		          <br>			  
			      </div></td>
				<td width="307">
					<div align="center"><a href="ShowNews?method=view">查看新闻</a> </div></td>
			</tr>
		</table>
</div>
	<c:choose>
		<c:when test="empty ${pageModel.list}">
			<c:if test="empty ${pageModel.list}"></c:if>
			<div align="center"><strong><font size="22" color="ff0000">暂无新闻信息！</font>		      </strong></div>
		</c:when>
		<c:otherwise>
		  <div align="center">
				<table border="1" width="800">
					<tr>
					  <td width="125" bgcolor="#33F2E9"><div align="center"><strong>序号</strong></div></td>
						<td width="557" bgcolor="#33F2E9"><div align="center"><strong>标 题</strong></div></td>
						<td width="96" bgcolor="#33F2E9"><div align="center"><strong>查看评论</strong></div></td>
					</tr>
					<c:forEach items="${pageModel.list}" var="news" varStatus="cul">
						<c:choose>
							<c:when test="${(cul.count) %2 == 0}">
							<tr align="center" bgcolor="#009AD8">
							</c:when>
							<c:otherwise>
							<tr align="center" bgcolor="#FF8040">
							</c:otherwise>
						</c:choose>
						<td>${cul.count}</td>
						<td><a href="newsDetailsServlet?method=details&nid=${news.nid}" title="点击查看详情！">${news.title}</a></td>
						<td><div align="center"><a href= "showCommentsServlet?method=comment&nid=${news.nid}" >查看评论</a></div></td>
					</c:forEach>
			</table>
          </div>
		  <div>
		      <table width="800" border="1" align="center">
                <tr>
                  <td bgcolor="#33F2E9"><div align="right">总记录：${pageModel.totalRecords} 当前：${pageModel.currentPage} / ${pageModel.totalPage}页 <a href="ShowNews?method=view&currentPage=${pageModel.previousPage}"  >上一页</a> <a href="ShowNews?method=view&currentPage=${pageModel.nextPage}" > 下一页</a>

				  
				  </div></td>
                </tr>
              </table>
		    </div>
			
		  <!--onclick="window.open('ShowNews?method=details&nid=${news.nid}','newwindow','height=768,width=1024,top=120,left=100,scrollbars=no')  -->
	  </c:otherwise>
	</c:choose>
</body>
</html>
